<template>
	<view class="box">
		<view class="head">
			<view class="contBack">
				
			</view>
			<image class="logo" src="/static/logo.png"></image>
			<view class="text-area">
				<view class="title1">登录</view>
				<view class="title2">**机场数字化施工管理平台</view>
			</view>
		</view>
		<view class="cont">
			<view class="contRow">
				<image src="../../static/1/1.png" mode=""></image>
				<input type="text" v-model="userName" placeholder="请输入用户名" />
				<image src="" mode=""></image>
			</view>
			<view class="contRow">
				<image src="../../static/1/2.png" mode=""></image>
				<input v-if="seen" type="text"  v-model="passwd" placeholder="请输入密码" style="left: 140rpx;position: absolute;border: none;" />
				<input v-else  type="password"  v-model="passwd" placeholder="请输入密码" style="left: 140rpx;position: absolute;border: none;" />
				<image :src="img ? '../../static/1/3.png' : '../../static/1/4.png' " mode="" @click="isshow"></image>
			</view>
			<view class="contRow login" style="border: none;" @click="login">
				<text>登录</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				seen: false,
				type_text: "text",
				type_password: "password",
				img:false,
				
				userName:'',
				passwd:''
			}
		},
		onLoad() {

		},
		methods: {
			isshow(){
				this.seen = !this.seen
				this.img = !this.img
			},
			
			login(){
				if(this.userName == false){
					uni.showToast({
						icon: 'none',
						title: '请输入用户名'
					})
				}
				if(this.passwd == false){
					uni.showToast({
						icon: 'none',
						title: '请输入密码'
					})
				}
				this.$HTTP('/users/login', {"userName": this.userName, "passwd": this.$code.encode64(this.passwd)}, 'POST').then((res) => {
					if(res && res.data && res.data.success){
						uni.setStorage({
							key: 'token',
							data: res.data.obj
						})
						uni.switchTab({
							url:'../index/index'
						})
					} else {
						uni.showToast({
							icon: 'none',
							title: '登录失败'
						})
					}
				})
				
				// uni.switchTab({
				// 	url:'../index/index'
				// })
				
			}

		}
	}
</script>

<style lang="scss">
	.head {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		height: 600rpx;
	}
	.contBack{
		width: 100%;
		height: 600rpx;
		position: absolute;
		top: 0;
		left: 0;
		z-index: 1;
		background: linear-gradient(to top, #ffffff, #d1e3fc);
	}

	.logo {
		height: 160rpx;
		width: 160rpx;
		margin-top: 100rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
		z-index: 2;
	}

	.text-area {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		z-index: 3;
	}

	.title1 {
		font-size: 40rpx;
		color: #000000;
		margin-left: 10rpx;
		font-weight: 600;
		letter-spacing: 8rpx;
		text-align: center;
	}
	.title2 {
		margin-top: 20rpx;
		font-size: 28rpx;
		color: #8f8f94;
		text-align: center;
	}
	.cont{
		margin: 20rpx 60rpx;
		// margin-top: 80rpx;
		// background-color: #000000;
		display: flex;
		flex-direction: column;
	}
	.cont .contRow{
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		width: 100%;
		height: 90rpx;
		margin-top: 40rpx;
		// padding: 0 10rpx;
		border-bottom: 1rpx #808080 solid;
	}
	.cont .contRow input{
		width: 480rpx;
		height: 60rpx;
		font-size: 32rpx;
		// background-color: #808080;
	}
	.cont .contRow image{
		width: 60rpx;
		height: 60rpx;
	}
	.cont .login{
		width: 100%;
		margin-top: 80rpx;
		background-color: #0251ff;
		color: #FFFFFF;
		text-align: center;
	}
	.cont .login text{
		width: 100%;
		
		color: #FFFFFF;
		text-align: center;
	}
</style>
